<extend name="Base/base" />
<block name="main">
        <!-- Content Header (Page header) -->
        <section class="content-header">
			<h1>
				菜单信息表
				<small>preview of simple tables</small>
			</h1>
			<ol class="breadcrumb">
				<li><a href="__MODULE__/Index/index"><i class="fa fa-dashboard"></i> 首页</a></li>
				<li><a href="#">菜单管理</a></li>
				<li class="active">列表</li>
			</ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-md-12">
              <div class="box">
                <div class="box-header with-border">
                  <h3 class="box-title"><i class="fa fa-th"></i> 菜单管理</h3>
                </div><!-- /.box-header -->
                <div class="box-body">
					<div class="form-group">
					<form action="__URL__/index" method="get" class="form-inline">
						<input class="form-control" id="exampleInputName2" placeholder="菜单名" type="text" name="mname" size="12">&nbsp;&nbsp;&nbsp;
						<input class="form-control" id="exampleInputName2" placeholder="数量" type="text" name="mnum" size="6">&nbsp;&nbsp;&nbsp;
						<input class="form-control" id="exampleInputName2" placeholder="￥" type="text" name="mprice1" size="6"> —
						<input class="form-control" id="exampleInputName2" placeholder="￥" type="text" name="mprice2" size="6">&nbsp;&nbsp;
						
						<input type="submit" value="搜索" class="btn btn-primary">
					</form>
					</div>
					<table class="table table-bordered table-hover">
					<thead>
						<tr>
						  <th style="width:50px">ID</th>
						  <th>店铺ID</th>
						  <th>菜名</th>
						  <th>单价</th>
						  <th>菜品图</th>
						  <th>已售出数量</th>
						  <th>所属分类标签</th>
						  <th>状态</th>
						  <th>添加时间</th>
						  <th style="width: 50px">操作</th>
						</tr>
					</thead>
					<tbody>
					<foreach name="list" item="me">
						<tr >
						  <td>{$me.id}</td>
						  <td>{$me.shopname}</td>
						  <td>{$me.menu}</td>
						  <td>￥{$me.price}</td>
						  <td><img src="__PUBLIC__/Uploads/s_{$me.menu_pic}"></td>
						  <td>{$me.num} 份</td>
						  <td>{$me.label_id}</td>
						  <!--<td>{$me.area}</td>-->
						  

						  <td id="change{$me.id}"><eq name="me.state" value="1">正在出售<else/>已下架</eq></td>
						  <td>{$me.addtime|date="Y-m-d",###}</td>
						  <td id="button{$me.id}">
							<!--<button class="btn btn-xs btn-danger" onclick="off({$me.id})">下架</button><br><br>
							<button class="btn btn-xs btn-info" onclick="on({$me.id})">上架</button>-->
							<if condition="$me.state eq 1 ">
								<button onclick="off({$me.id},this);" class="btn btn-xs btn-danger" title="点击上架">下架</button>
							<else/>
								<button onclick="on({$me.id},this);" class="btn btn-xs btn-primary" title="点击下架">上架</button>
							</if>
						  </td>
						</tr>
                </foreach>
				</tbody>
                  </table>
				
                </div><!-- /.box-body -->
                <div class="box-footer clearfix">
                  <ul class="pagination pagination-sm no-margin pull-right">
                     {$pageinfo}
                  </ul>
                </div>
              </div><!-- /.box -->

            </div><!-- /.col -->
            
          </div><!-- /.row -->
         
        </section><!-- /.content -->
 </block>
 <block name="myscript">
	<script>
		//执行下架
		function off(id){
			Modal.confirm({msg:"确定下架吗？"}).on(function(e){
				if(e){
					$.ajax({
						type:'GET',             //请求方式GET
						url :'__URL__/off',           //ajax请求地址
						data:'id='+id, //请求传递的参数
						dataType:'json',        //预期服务器返回的数据类型
						async : true,           //是否异步
						success: function(res){
							//alert(res.id);
							if(res != "null"){
								$("#button"+res.id).html("<button onclick='on("+res.id+");' class='btn btn-xs btn-primary' title='点击下架'>上架</button>");
								$("#change"+res.id).html("已下架");
							}
						},  //ajax成功后的回调函数
					});
				}
			});	
		}
		//重新上架
		function on(id){
			Modal.confirm({msg:"确定重新上架吗？"}).on(function(e){
				if(e){
					$.ajax({
						type:'GET',             //请求方式GET
						url :'__URL__/on',           //ajax请求地址
						data:'id='+id, //请求传递的参数
						dataType:'json',        //预期服务器返回的数据类型
						async : true,           //是否异步
						success: function(res){
							//alert(res.id);
							if(res != "null"){
								$("#button"+res.id).html("<button onclick='off("+res.id+");' class='btn btn-xs btn-danger' title='点击上架'>下架</button>");
								$("#change"+res.id).html("正在出售");
							}
						},  //ajax成功后的回调函数
					});
				}
			});
		}
		
	</script>
 </block>